<template>
  <div>
    <!-- -->
    <h1>新增用户</h1>
    <form>
        <p>登录名：<input type="text" v-model="user.loginName"></p>
        <p>用户名：<input type="text" v-model="user.empName"></p>
        <p>密码：<input type="text" v-model="user.password"></p>
        <p>职位：<input type="text" v-model="user.position"></p>
        <p>邮箱：<input type="text" v-model="user.email"></p>
        <p>联系方式：<input type="text" v-model="user.phoneNumber"></p>
        <p>工资：<input type="text" v-model="user.salary"></p>
        <button @click.prevent="addUsser">添加</button>
        <button @click.prevent="back">返回</button>
    </form>
  </div>
</template>

<script>
import {addUser} from '@/api/user'
export default {
  name: 'VueTest04AddUser',

  data() {
    return {
      user:{}
    };
  },

  mounted() {

  },

  methods: {
    addUsser(){
        var params = this.user;
        addUser(params).then(data=>{
            this.user = {}
            this.$router.replace({path:'/user'})
        })
    },
    back(){
        this.$router.replace({path:'/user'})
    }
  },
};
</script>